package com.jic.market.controller.manage;

import com.jic.common.base.vo.RestResult;
import com.jic.market.api.manage.PromotionGiftItemApi;
import com.jic.market.request.PromotionGiftItemBatchRequest;
import com.jic.market.request.PromotionGiftItemRequest;
import com.jic.market.response.PageResponse;
import com.jic.market.response.PromotionGiftItemResponse;
import com.jic.market.service.PromotionGiftItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * description: PromotionGiftItemManageController
 * date: 2020/3/2 14:38
 * author: wangys
 * version: 1.0
 */
@RestController
@RequestMapping("promotionGiftItem")
public class PromotionGiftItemManageController implements PromotionGiftItemApi {
    @Autowired
    PromotionGiftItemService promotionGiftItemService;

    @Override
    @PostMapping("listByPage")
    public RestResult<PageResponse<PromotionGiftItemResponse>> listByPage(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.listByPage(request));
    }

    @Override
    @PostMapping("saveBatch")
    public RestResult<Integer> saveBatch(@RequestBody PromotionGiftItemBatchRequest request) {
        return RestResult.success(promotionGiftItemService.saveBatch(request));
    }

    @Override
    @PostMapping("deleteBatch")
    public RestResult<Integer> deleteBatch(@RequestBody PromotionGiftItemBatchRequest request) {
        return RestResult.success(promotionGiftItemService.deleteBatch(request));
    }

    @Override
    @PostMapping("deleteById")
    public RestResult<Integer> deleteById(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.deleteById(request));
    }

    @Override
    @PostMapping("findAll")
    public RestResult<List<PromotionGiftItemResponse>> findAll(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.findAll(request));
    }

    @Override
    @PostMapping("detail")
    public RestResult<PromotionGiftItemResponse> detail(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.detail(request));
    }

    @PostMapping("update")
    public RestResult<Integer> update(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.update(request));
    }

    @PostMapping("countByPromotionId")
    public RestResult<Integer> countByPromotionId(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.countByPromotionId(request));
    }

    @PostMapping("checkTimeliness")
    public RestResult<String> checkTimeliness(@RequestBody PromotionGiftItemRequest request) {
        return RestResult.success(promotionGiftItemService.checkTimeliness(request));
    }
}
